import React from 'react'
// ===================================================================== Temp
import TableModal from '#cpt/temp/TableModal'
// ===================================================================== Declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const $cache = $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		selectedKeys:[],
		selectedRows: [],
		forms : [
			{ label: '自然项目',		name: 'parent_kind_id',	type: 'select', width:250 },
		]
	}
	
	model = {}
	
	// 获取下拉数据
	getSelect = () => {
		const { forms } = this.state
		$cache.then( async f => {
			// 自然项目
			$fn.setRow(forms, 'parent_kind_id',  await f.getCache({ api:'nature_project' } ))
			// 
			this.setState({ forms })
		})
	}
	
	open = (title,{rows, query, cross_page_submit, use_old_approve_at}) => {
		this.modal.open()
		// 搜索参数
		const { experiment_num, spec_code } = rows
		this.query = { experiment_num, spec_code }
		// 提交参数
		this.submit = {...query,type:1, control:1, cross_page_submit, use_old_approve_at }
		// 获取下拉数据
		if(!$fn.hasArray(this.state.forms[0].data)){ this.getSelect() }
		//
		this.setState({ title })
		//
		this.fetch()
	}
	// paging
	fetch = () => $fn.fetch.call(this, 'ts-report-card/combkindlists', { paging:'get' })
	
	// 表单
	cols = [
		{ title: '标本条码', 	dataIndex: 'spec_code', 				...$fn.table.spec_code },
		{ title: '状态', 		dataIndex: 'status_name', 				width:80 },
		{ title: '自然项目', 	dataIndex: 'parent_kind_name', 			width:250 },
		{ title: '实验号', 		dataIndex: 'experiment_num', 			...$fn.table.exp_num },
		{ title: '项目名称', 	dataIndex: 'kind_name', 				width:250 },
		{ title: '姓名', 		dataIndex: 'patient_name', 				...$fn.table.name  },
	]
	
	render(){
		return (
			<>
				{
					TableModal.call(this,{ 
						title:'批准', width:'80%', minWidth:800, height:'80%',  table:{ width:1200 }, api:'ts-report-card/upaudit',
						getSubmit: ids => ( { ids } )
					})
				}
			</>
		)
	}
}

export default Index